*
***************************************
*Robustness Table on skewness measures*
***************************************
*
use tempfirst, clear
global nbnc8iso2 " "
global nbnc8iso2_d1 " "
eststo clear
set more off
scalar drop _all
egen isiciso = group(isic iso2_d)
*
foreach lhs in theil_d1 theil_dconst lratiow_d1  atk5_d1 atk10_d1 atk20_d1 atk5_dconst atk10_dconst atk20_dconst{
foreach rhs in  ltradeshock6 ltradeshock6i {
if `rhs' == ltradeshock6 {
eststo: reghdfe `lhs' `rhs' lgdpcapshock6 $nbnc8iso2_d1 yd* ,  cluster(firmiso) a(firmiso)
}
if `rhs' == ltradeshock6i {
eststo: reghdfe `lhs' `rhs' lgdpcapshock6 $nbnc8iso2_d1 yd* ,  cluster(isiciso) a(firmiso)
}
scalar b_`rhs'_`lhs' = string(round(_b[`rhs'],0.001),"%9.3f")
scalar se_`rhs'_`lhs' = string(round(_se[`rhs'],0.001),"%9.3f")
scalar t_`rhs'_`lhs' = _b[`rhs']/_se[`rhs']
}
}
*
log using $DIRLOG/Replication/skewregs_boston1ststage_FEFDrob_rev.txt, text replace
set linesize 250
esttab, drop(yd* ) b(%4.3f) se(%4.3f) r2 starlevels({$^c$} 0.1 {$^b$} 0.05 {$^a$} 0.01)  tex  title() label
esttab, drop(yd* ) compress r2 starlevels(c 0.1 b 0.05 a 0.01)  b(%4.3f) se(%4.3f)
eststo clear
*
* Show graph of contribution of the intensive margin Theil to total Theil
corr theil_d1 theil_dconst 
global coef = round(r(rho),0.01)
*binscatter theil_d1 theil_dconst 
scatter theil_d1 theil_dconst, msymbol(p) text(3.5 -1.5  "Correlation Coeff = $coef") scheme(mys2color)
graph export $DIRLOG/Replication/theil_dconst_corr.png, as(png) replace
graph save $DIRLOG/Replication/theil_dconst_corr, replace
*
log close
*
scalar list
clear
set obs 1
foreach rhs in  ltradeshock6 ltradeshock6i {
foreach lhs in theil_d1 theil_dconst lratiow_d1  atk5_d1 atk10_d1 atk20_d1 atk5_dconst atk10_dconst atk20_dconst{
qui gen str5 star_`rhs'_`lhs'=""
qui replace star_`rhs'_`lhs' = "$ ^{c}$" if t_`rhs'_`lhs'>1.645 & t_`rhs'_`lhs'!=.
qui replace star_`rhs'_`lhs' = "$ ^{b}$" if t_`rhs'_`lhs'>1.96 & t_`rhs'_`lhs'!=.
qui replace star_`rhs'_`lhs' = "$ ^{a}$" if t_`rhs'_`lhs'>2.326 & t_`rhs'_`lhs'!=.
qui scalar b_`rhs'_`lhs' = b_`rhs'_`lhs'  + star_`rhs'_`lhs'
}
}
scalar list

*
* Creating table 4:
file open table using $DIRLOG/Replication/tab-firststagetrue-rob-skewmeasures.tex, write replace
file write table ///
"$\tilde{\Delta}$ trade Shock " " & " (b_ltradeshock6_theil_d1)  " & " (b_ltradeshock6_atk5_d1) " & " (b_ltradeshock6_atk10_d1) " & " (b_ltradeshock6_atk20_d1)  " & "  (b_ltradeshock6_theil_dconst) " & " (b_ltradeshock6_atk5_dconst) " & " (b_ltradeshock6_atk10_dconst) " & " (b_ltradeshock6_atk20_dconst)   " \\" ///
_n "  " " & (" (se_ltradeshock6_theil_d1)  ") & (" (se_ltradeshock6_atk5_d1)  ") & (" (se_ltradeshock6_atk10_d1)  ") & (" (se_ltradeshock6_atk20_d1)  ") & ("  (se_ltradeshock6_theil_dconst) ") & (" (se_ltradeshock6_atk5_dconst)  ") & (" (se_ltradeshock6_atk10_dconst)  ") & (" (se_ltradeshock6_atk20_dconst)  ")  \\" ///
_n "$\tilde{\Delta}$ trade Shock - ISIC " " & " (b_ltradeshock6i_theil_d1) " & " (b_ltradeshock6i_atk5_d1) " & " (b_ltradeshock6i_atk10_d1) " & " (b_ltradeshock6i_atk20_d1) " & "  (b_ltradeshock6i_theil_dconst)  " & " (b_ltradeshock6i_atk5_dconst) " & " (b_ltradeshock6i_atk10_dconst) " & " (b_ltradeshock6i_atk20_dconst)  " \\" ///
_n "  " " & (" (se_ltradeshock6i_theil_d1)  ") & (" (se_ltradeshock6i_atk5_d1)  ") & (" (se_ltradeshock6i_atk10_d1)  ") & (" (se_ltradeshock6i_atk20_d1)  ") & ("  (se_ltradeshock6i_theil_dconst) ") & (" (se_ltradeshock6i_atk5_dconst)  ") & (" (se_ltradeshock6i_atk10_dconst)  ") & (" (se_ltradeshock6i_atk20_dconst)  ")  \\" 
file close table

